<!--
 * @Author: 熔岩巨兽 2141826215@qq.com
 * @Date: 2024-09-02 20:38:26
 * @LastEditTime: 2024-09-02 21:29:24
 * @LastEditors: 熔岩巨兽 2141826215@qq.com
 * @FilePath: \vue-vite-project\src\views\CommunicationMode\UseAttrRefParent\children2.vue
 * Copyright (c) 2024 by 熔岩巨兽 2141826215@qq.com, All Rights Reserved. 
-->
<!--
 * @Author: 熔岩巨兽 2141826215@qq.com
 * @Date: 2024-09-02 20:38:26
 * @LastEditTime: 2024-09-02 20:38:59
 * @LastEditors: 熔岩巨兽 2141826215@qq.com
 * @FilePath: \vue-vite-project\src\views\CommunicationMode\UseAttrRefParent\children2.vue
 * Copyright (c) 2024 by 熔岩巨兽 2141826215@qq.com, All Rights Reserved. 
-->
<template>
  <div class="children_warpper">
    <div>
      {{ name }}
    </div>
    <div>
      <h2>父组件传递的信息</h2>
      <div>儿子的钱：{{ monye }}</div>
      <button @click="getBaba($parent)">拿爸爸100000</button>
    </div>
  </div>
</template>

<script lang="ts" setup name="children2">
import { ref } from "vue";
const name = ref("我是子组件2");
//子组件接收父组件传递的信息  //可以书数组 也可以是对象
let propsInfo = defineModel();
let monye = ref(888888);
console.log(propsInfo);
defineExpose({ monye });
const getBaba = ($parent: any) => {
  monye.value += 100000;
  $parent.mony -= 100000;
  console.log($parent.mony);
};
// let propsInfos = defineProps({
//   info:{
//     type: String,
//     required: true
//   },
//   parentInfo: {
//     type: String,
//     required: true
//   },
//   parentCard: {
//     type: Object,
//     required: true
//   },
//   info2: {
//     type: String,
//     default: '我是默认值'
//   },
// })
function printInfo() {
  // 确保 propsInfo 已定义
  if (!propsInfo.value) {
    console.error("propsInfo is not defined.");
    return;
  }

  // console.log(propsInfos);
  // console.log(propsInfos.info2);
}
</script>

<style scoped>
.children_warpper {
  height: 100%;
  padding: 20px;
  background-color: gold;
  color: #000;
}
</style>
